# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=openjpeg
pkgver=2.5.0
pkgrel=3
pkgdesc="Open-source implementation of JPEG2000 image codec"
url="https://www.openjpeg.org/"
arch="all"
options="!check"  # No test suite.
license="BSD-2-Clause-NetBSD"
# Some of the development CMake files installed by -dev depend on tools provided by the -tools subpackage
depends_dev="$pkgname-tools"
makedepends="libpng-dev tiff-dev lcms2-dev doxygen cmake samurai"
subpackages="$pkgname-dev $pkgname-tools"
source="https://github.com/uclouvain/openjpeg/archive/v$pkgver/openjpeg-v$pkgver.tar.gz
	fix-cmakelists.patch
	"

# secfixes:
#   2.5.0-r0:
#     - CVE-2021-3575
#     - CVE-2022-1122
#   2.4.0-r1:
#     - CVE-2021-29338
#   2.4.0-r0:
#     - CVE-2020-27844
#   2.3.1-r6:
#     - CVE-2020-27814
#     - CVE-2020-27823
#     - CVE-2020-27824
#   2.3.1-r5:
#     - CVE-2019-12973
#     - CVE-2020-15389
#   2.3.1-r3:
#     - CVE-2020-6851
#     - CVE-2020-8112
#   2.3.0-r3:
#     - CVE-2018-5785
#   2.3.0-r2:
#     - CVE-2018-14423
#     - CVE-2018-6616
#   2.3.0-r1:
#     - CVE-2017-17480
#     - CVE-2018-18088
#   2.3.0-r0:
#     - CVE-2017-14039
#   2.2.0-r2:
#     - CVE-2017-14040
#     - CVE-2017-14041
#     - CVE-2017-14151
#     - CVE-2017-14152
#     - CVE-2017-14164
#   2.2.0-r1:
#     - CVE-2017-12982
#   2.1.2-r1:
#     - CVE-2016-9580
#     - CVE-2016-9581

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DOPENJPEG_INSTALL_LIB_DIR=lib
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

tools() {
	pkgdesc="$pkgdesc - tools"
	amove usr/bin
}

sha512sums="
08975a2dd79f1e29fd1824249a5fbe66026640ed787b3a3aa8807c2c69f994240ff33e2132f8bf15bbc2202bef7001f98e42d487231d4eebc8e503538658049a  openjpeg-v2.5.0.tar.gz
b50cd382d08647db18f202769aae7df87613a18143a30e360e8f00aba1ec1b7fd0a153685dbea3950bc5623b06c314326777c4fb7aff56adfc6b17bc74c933e5  fix-cmakelists.patch
"
